﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AccountServiceReference;
using System.ServiceModel;

public partial class UserControl_ChangePassword : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex = 0;
    }

    protected void lbtnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            var client = new AccountServiceClient();
            var username = txtUsername.Text.Trim();
            var email = txtEmail.Text.Trim();
            var password = txtPassword.Text.Trim();
            var newPassword = txtNewPassword.Text.Trim();
            var result = client.UpdatePassword(username, email, password, newPassword);
            if (result)
            {
                MultiView1.ActiveViewIndex = 1;
            }
            else
            {
                msg.Text = "Information not found!";
            }
        }
        catch (FaultException<Account> faultException)
        {
            msg.Text = faultException.Message;
        }
        catch (Exception ex)
        {
            msg.Text = ex.Message;
        }
    }
}